/*  1:   */ package org.jetbrains.debugger;
/*  2:   */ 
/*  3:   */

import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.ActionCallback.Done;
import com.intellij.openapi.util.AsyncResult;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.concurrent.atomic.AtomicReference;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */ 
/* 10:   */ public abstract class SuspendContextManagerBase<T extends SuspendContextBase, CALL_FRAME extends CallFrame>
/* 11:   */   implements SuspendContextManager<CALL_FRAME>
/* 12:   */ {
/* 13:11 */   protected final AtomicReference<T> context = new AtomicReference();
/* 14:13 */   protected final AtomicReference<ActionCallback> suspendCallback = new AtomicReference();
/* 15:   */   
/* 16:   */   public final void setContext(T paramT)
/* 17:   */   {
/* 18:16 */     if (!this.context.compareAndSet(null, paramT)) {
/* 19:17 */       throw new IllegalStateException("Attempt to set context, but current suspend context is already exists");
/* 20:   */     }
/* 21:   */   }
/* 22:   */   
/* 23:   */   public final void contextDismissed(T paramT, @NotNull DebugEventListener paramDebugEventListener)
/* 24:   */   {
/* 25:22 */     if (paramDebugEventListener == null) {
/* 26:22 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/debugger/SuspendContextManagerBase", "contextDismissed" }));
/* 27:   */     }
/* 28:22 */     if (!this.context.compareAndSet(paramT, null)) {
/* 29:23 */       throw new IllegalStateException("Expected " + paramT + ", but another suspend context exists");
/* 30:   */     }
/* 31:25 */     paramDebugEventListener.resumed();
/* 32:   */   }
/* 33:   */   
/* 34:   */   @Nullable
/* 35:   */   public final T getContext()
/* 36:   */   {
/* 37:31 */     return (SuspendContextBase)this.context.get();
/* 38:   */   }
/* 39:   */   
/* 40:   */   @NotNull
/* 41:   */   public T getContextOrFail()
/* 42:   */   {
/* 43:37 */     SuspendContextBase localSuspendContextBase = getContext();
/* 44:38 */     if (localSuspendContextBase == null) {
/* 45:39 */       throw new IllegalStateException("No current suspend context");
/* 46:   */     }
/* 47:41 */     SuspendContextBase tmp20_19 = localSuspendContextBase;
/* 48:41 */     if (tmp20_19 == null) {
/* 49:41 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/debugger/SuspendContextManagerBase", "getContextOrFail" }));
/* 50:   */     }
/* 51:41 */     return tmp20_19;
/* 52:   */   }
/* 53:   */   
/* 54:   */   @NotNull
/* 55:   */   public final ActionCallback suspend()
/* 56:   */   {
/* 57:47 */     ActionCallback localActionCallback = (ActionCallback)this.suspendCallback.get();
/* 58:48 */     if (localActionCallback != null)
/* 59:   */     {
/* 60:49 */       ActionCallback tmp16_15 = localActionCallback;
/* 61:49 */       if (tmp16_15 == null) {
/* 62:49 */         throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/debugger/SuspendContextManagerBase", "suspend" }));
/* 63:   */       }
/* 64:49 */       return tmp16_15;
/* 65:   */     }
/* 66:52 */     if (this.context.get() != null)
/* 67:   */     {
/* 68:53 */       void tmp68_65 = new ActionCallback.Done();
/* 69:53 */       if (tmp68_65 == null) {
/* 70:53 */         throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/debugger/SuspendContextManagerBase", "suspend" }));
/* 71:   */       }
/* 72:53 */       return tmp68_65;
/* 73:   */     }
/* 74:55 */     localActionCallback = new ActionCallback();
/* 75:56 */     doSuspend(localActionCallback).notifyWhenRejected(localActionCallback); ActionCallback 
/* 76:57 */       tmp122_121 = localActionCallback;
/* 77:57 */     if (tmp122_121 == null) {
/* 78:57 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/debugger/SuspendContextManagerBase", "suspend" }));
/* 79:   */     }
/* 80:57 */     return tmp122_121;
/* 81:   */   }
/* 82:   */   
/* 83:   */   protected abstract ActionCallback doSuspend(ActionCallback paramActionCallback);
/* 84:   */   
/* 85:   */   public boolean isContextObsolete(@NotNull SuspendContext paramSuspendContext)
/* 86:   */   {
/* 87:64 */     if (paramSuspendContext == null) {
/* 88:64 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/SuspendContextManagerBase", "isContextObsolete" }));
/* 89:   */     }
/* 90:64 */     return this.context.get() != paramSuspendContext;
/* 91:   */   }
/* 92:   */   
/* 93:   */   public void setOverlayMessage(@Nullable String paramString) {}
/* 94:   */   
/* 95:   */   @NotNull
/* 96:   */   public final AsyncResult<Boolean> restartFrame(@NotNull CALL_FRAME paramCALL_FRAME)
/* 97:   */   {
/* 98:74 */     if (paramCALL_FRAME == null) {
/* 99:74 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/debugger/SuspendContextManagerBase", "restartFrame" }));
/* :0:   */     }
/* :1:74 */     AsyncResult tmp49_46 = restartFrame(paramCALL_FRAME, getContextOrFail());
/* :2:74 */     if (tmp49_46 == null) {
/* :3:74 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/debugger/SuspendContextManagerBase", "restartFrame" }));
/* :4:   */     }
/* :5:74 */     return tmp49_46;
/* :6:   */   }
/* :7:   */   
/* :8:   */   @NotNull
/* :9:   */   protected abstract AsyncResult<Boolean> restartFrame(@NotNull CALL_FRAME paramCALL_FRAME, @NotNull T paramT);
/* ;0:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.debugger.SuspendContextManagerBase

 * JD-Core Version:    0.7.0.1

 */